from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
import time


def Driver():
	# option = webdriver.ChromeOptions()
	# option.add_experimental_option("detach", True)
	# option.add_experimental_option('excludeSwitches', ['enable-automation'])
	# driver = webdriver.Chrome(
    #         executable_path='C://Users//13972//AppData//Local//Programs//Python//Python39//Scripts//chromedriver.exe', options=option)
	# driver = webdriver.Chrome('C://Users//13972//AppData//Local//Programs//Python//Python39//Scripts//chromedriver.exe',options=option)

	driver = webdriver.Chrome()
	# driver = webdriver.PhantomJS()
	driver.get('https://search.51job.com/list/170200,000000,0000,32,9,99,%25E4%25BA%25A7%25E5%2593%2581%25E7%25BB%258F%25E7%2590%2586,2,1.html?lang=c&postchannel=0000&workyear=99&cotype=99&degreefrom=99&jobterm=99&companysize=99&ord_field=0&dibiaoid=0&line=&welfare=')
	# iframe = driver.find_element_by_id('g_iframe')
	# driver.switch_to.frame(iframe)
	# print(iframe)
	name = driver.find_element_by_class_name('j_joblist')
	# 打印标签名(只能打印单个元素内容，不能打印list类型)
	# for i in name:
	# 	print(i.tag_name) # a
	# 打印当前元素的属性值
	# for i in name:
	# 	print(i.get_attribute('title')) #a元素内title的内容
	# 打印当前元素的文本内容
	# for i in name:
		# print(i.text)
	# 打印当前元素的上一级
	# print(name.parent)
	# 执行js脚本
	# driver.execute_script(js)
	ActionChains(driver).move_to_element(name).click(name).perform()
	# e = driver.find_element_by_xpath('/html/body/div[2]/div[3]/div/div[2]/div[4]/div[1]/div[1]/a/p/span[1]/@title')
	# print(e)
	time.sleep(1)
    
    

if __name__ == '__main__':
	Driver()
